Repository navigation
nginx, Compose and the web deploy learn the selector commentsShadow - #3400
Merged
Merged
Conversation
…ndler, switched off and never served The handler admits an ordinary comment from an existing participant and hands everything else back to Node before anything is written, each under a named reason. The comment and its author's vote are written in one transaction; a write PostgreSQL provably refused is handed back to Node. A conversation with strict moderation reaches a typed decision the live path cannot write. The comment's text is held in a type that cannot be printed. Off unless POLIS_API_POST_COMMENTS=1; no nginx route sends a comment to this server. Co-Authored-By: Claude <noreply@anthropic.com>
…stener that serves two mirrored routes Built only by the shadow role when POLIS_API_POST_COMMENTS=observe, which nothing sets. The observer runs the live handler's own checks and admission statement on read-only pools, says what the live handler would do with each copied comment, reads back what Node stored and prints one line of classes: no conversation, comment or participant number, no text. The shadow listener serves its mirrored routes from a table, each with its own lane, bound, rate bucket and pools; the vote observations are unchanged. Co-Authored-By: Claude <noreply@anthropic.com>
When RUST_API_ROUTES names commentsShadow, nginx copies each POST /api/v3/comments to the read-only shadow service under its own rate limit, the deploy hook passes the shadow service its comment switch through the Compose override it already writes, and validation requires the shadow's health to report the comment observer exactly. Nothing names it: for every existing selection nginx renders the same bytes and validation gives the same verdicts. Co-Authored-By: Claude <noreply@anthropic.com>
The change this branch was stacked on is now on edge as one squashed commit. Git sees the squashed files and the branch's copies as two separate additions; each such file is resolved to the side that changed it since the old base (no file was changed on both sides). The result differs from edge by exactly this branch's own change.
Contributor
Delphi Coverage Report
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Observable changes: none while
RUST_API_ROUTESdoes not namecommentsShadow, as nowhere does. For every selection the previous renderer accepts, nginx renders the same bytes; the shadow service starts with the same image, limits and settings plus three environment entries that are inert while its comment switch is empty; the deploy's validation gives the same verdicts, and additionally requires that the shadow service has no comment observer when the name is not selected.What it adds, for when the name is selected:
commentsShadowrenders the mirror ofPOST /api/v3/commentsto the shadow service from the vote shadow's own templates, with the name and the path replaced: Node answers every comment exactly as before, with one added request header (X-Request-Id), and a copy goes topolis-api-shadow. The access line of a shadowed comment and the two JSON lines are the vote shadow's formats. With the comment read route selected too, the POST diversion is inserted into that route's location. Both shadows together is the ordinary selection.limit_reqzone, used in the copy's location only: 2 a second on a box and 4 more at once. A copy over the rate ends there with 429; the request Node answers is never counted, delayed or refused.after_install.shderives the switch from the route list, writes it into the Compose override it generates, checks the composed value before it replaces anything, and starts the shadow service when either shadow is selected.validate_service.shrequires the shadow's/healthto show the comment observer (observe mode, never enabled, its two read-only pools, room for 8 and 64, at most 6 a second) exactly whencommentsShadowis selected.commentsShadowwithpostComments, the name reserved for a route that writes comments, is refused by both.What the mirror does to a comment POST: nginx reads the whole body before it contacts Node. For a body that arrives whole, as every real comment does, Node has the request no later than before; a slow body reaches Node when its last byte has arrived; a body too long to hold in memory, which is never a valid comment and never copied, goes through a temporary file. The reply is the same bytes in every case, and with the shadow service answering, absent, silent, slow, answering 404 or answering 500.
Order: deploy a release that knows the name before the name is selected, and remove the name before deploying an older release. A renderer that does not know a name refuses the whole list and sends every route to Node while that release's validation still passes (
file-server/nginx/ROUTING.md, "The comment shadow").Tests: the routing suite checks each rendered location line by line against the vote shadow's; the behaviour suite runs the comment shadow behind the production nginx image in nine modes of the shadow stand-in, both shadows together, reads on the comment path, the rate, and bodies from 180 bytes to the largest nginx and Node accept;
shadow-stack.shruns real comments through nginx to the real Node server with the real shadow service underdocker-compose.yml, started without the switch, with it, paused and stopped, and compares Node's replies byte for byte; the hook, validation and health predicate tests cover every pairing of the route list with what the service reports.No schema change, no migration, no Node change, no Rust change.
Order matters when the name is ever selected: this release first, the secret second. A release without this change deployed while the route list names
commentsShadowrefuses the whole list, so every Rust route goes back to Node and the vote copies stop, while that release's validation still passes; "released" means the web deployment group's last successful revision, since an Auto Scaling launch deploys that.ROUTING.mdsays so.Known limits, each a follow-up and none affecting a person: a copy carries no query string, so a comment whose parameters travelled there is observed without them (the repository's clients use the body); with a shadow selected nginx buffers every POST to the mirrored path before proxying (as it has for votes since the vote shadow), including bodies that will not be copied.
The hosted
polis-apijob's time limit goes from 40 to 60 minutes: the new behaviour and stack tests add about ten minutes to a job that ran in about thirty.Stacked on the pull request that adds the comments observe mode (PR #3398); the diff shown is this change alone. Reviewed independently; the reviewer re-derived the no-change result (971 route lists render byte-identical nginx) and reproduced the rollback behaviour.
🤖 Generated with Claude Code